package domain;

import java.text.SimpleDateFormat;
import java.util.Date;

public class PostDO {
	
	String  id;
	Date  pubDate;
	String  user;
	String  title;
	String  content;
	String  tags;
	
	public PostDO(String id, String user, Date pubDate, String title, String content, String tags){
		 this.id = id;
		 this.user = user;
		 this.title = title;
		 this.pubDate = pubDate;
		 this.content = content;
		 this.tags = tags;
	}

	/**
	 * @return the  id
	 */
	public String getId() {
		return id;
	}
	
	/**
	 * @return the user
	 */
	public String getUser() {
		return user;
	}

	/**
	 * @return the  title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * @param  title the  title to set
	 */
	public void setTitle(String  title) {
		this. title = title;
	}

	/**
	 * @return the  pubDate
	 */
	public Date getPubDate() {
		return  pubDate;
	}

	/**
	 * @param  pubDate the  pubDate to set
	 */
	public void setPubDate(Date  pubDate) {
		this. pubDate = pubDate;
	}

	/**
	 * @return the  content
	 */
	public String getContent() {
		return content;
	}

	/**
	 * @param  content the  content to set
	 */
	public void setContent(String  content) {
		this. content = content;
	}

	/**
	 * @return the  lTags
	 */
	public String getLTags() {
		return tags;
	}

	/**
	 * @param  lTags the  lTags to set
	 */
	public void setLTags(String tags) {
		this.tags = tags;
	}
	
	public boolean isContainsTag(String tag){
		return this.tags.contains(tag);
	}
		
	public boolean equals(Object o){
		if(!(o instanceof PostDO))
			return false;
		PostDO p = (PostDO)o;
		return this. id == p. id && this.user.equals(p.getUser()); 
	}
	
	public String toString(){
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return  "{'id':'"+ id + "','pubDate':'"+df.format(pubDate)+"','user':'" + user + "','title':'"+title+"','content':'"+content+"','tags':'"+tags+"'}";
	}
}
